import { defineStore } from 'pinia'
import { orgTreeSelect, userList } from "@/service/dict"
export const useDict = defineStore('dict', {
    state: () => {
        return {
            userLdList: [],
            orgList: []
        }
    },
    actions: {
        // 获取分管领导
        async getUserLdList() {
            let res = await userList({
                "pageNo": 1,
                "pageSize": 20,
                "orgCode": "B_10001"
            })
            if (res.code == 0) {
                this.userLdList = res.data.records
            }
        },
        // 获取组织架构
        async getOrgTreeSelect() {
            let res = await orgTreeSelect()
            if (res.code == 0) {
                this.orgList = res.dataList.map(item => {
                    item.newName = item.name
                    return item
                })
            }
        },
        async initDict() {
            await this.getUserLdList()
            await this.getOrgTreeSelect()
        }
    }
})